package GameSrc;

import javax.imageio.ImageIO;
import java.awt.*;
import java.io.File;
import java.io.IOException;

public abstract class GameObject {
    private int width;
    private int height;
    private int x;
    private int y;
    private Image img;

    private GameWindow gameWindow;

    private Rectangle rectangle;

    public GameObject() {
    }

    public GameObject(int width, int height, int x, int y, String img, GameWindow gameWindow) {
        this.width = width;
        this.height = height;
        this.x = x;
        this.y = y;
        try {
            this.img = ImageIO.read(new File(img));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        this.gameWindow = gameWindow;
        this.rectangle = new Rectangle(x,y,width,height);
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }

    public Image getImg() {
        return img;
    }

    public void setImg(String img) {
        try {
            this.img = ImageIO.read(new File(img));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public void renewalRec(int x, int y,int width, int height){
        setRec(new Rectangle(x,y,width,height));
    }
    public Rectangle getRectangle() {
        return rectangle;
    }

    public void setRec(Rectangle rectangle) {
        this.rectangle = rectangle;
    }

    public GameWindow getGameWindow() {
        return gameWindow;
    }
}
